version 13      
clear all
set more off 

use "conjoint_scenariolevel.dta", clear

* Set dataset as survey dataset with weights
svyset [pweight = weight]

global attributes="damage_1m damage_4m damage_24m fatal_5 inc70 inc40 inc10 unemp_5 unemp_7 unemp_9 presvote_40D presvote_30D presvote_60D presvote_70D"
global att_dam="fatal_5 inc70 inc40 inc10 unemp_5 unemp_7 unemp_9 presvote_40D presvote_30D presvote_60D presvote_70D"
global attributesrev="damage_100k damage_1m damage_4m fatal_none inc100 inc70 inc40 unemp_3 unemp_5 unemp_7 presvote_50D presvote_40D presvote_30D presvote_60D"


************
* Appendix Tables A4, A5, A6, A7 and A10
***************

* Appendix Table A.4: Full Subgroup Results
reg relief_ $attributes [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA4.xls", ctitle("") excel bdec(3) sdec(3) stats(coef se) replace

reg relief_ $attributes if aff_norm_high==0 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA4.xls", ctitle("Affectedness-based Fairness: Low") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributes if aff_norm_high==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA4.xls", ctitle("Affectedness-based Fairness: High") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributes if need_norm_high==0 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA4.xls", ctitle("Need-based Fairness: Low") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributes if need_norm_high==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA4.xls", ctitle("Need-based Fairness: High") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributes if gvt_prio_high==0 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA4.xls", ctitle("Electorally Reciprocity: Low") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributes if gvt_prio_high==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA4.xls", ctitle("lectorally Reciprocity: High") excel bdec(3) sdec(3) stats(coef se) append

* Appendix Table A.5: Alternative Measure of Electoral Reciprocity
reg relief_ $attributes [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA5.xls", ctitle("Main") excel bdec(3) sdec(3) stats(coef se) replace

reg relief_ $attributes if pol_ties_high==0 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA5.xls", ctitle("Electoral Reciprocity: Low") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributes if pol_ties_high==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA5.xls", ctitle("Electoral Reciprocity: High") excel bdec(3) sdec(3) stats(coef se) append

* Appendix Table A.6: Main results and by damage levels
reg relief_ $attributes [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA6.xls", ctitle("Main") excel bdec(3) sdec(3) stats(coef se) replace

reg relief_ $attributes if totaldamageunder10m==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA6.xls", ctitle("Total Damage: $10m or less") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributes if totaldamageunder10m==0 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA6.xls", ctitle("Total Damage: more than $10m") excel bdec(3) sdec(3) stats(coef se) append

* Appendix Table A.7: Recoded Reference Groups
reg relief_ $attributesrev [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA7.xls", ctitle("") excel bdec(3) sdec(3) stats(coef se) replace

reg relief_ $attributesrev if aff_norm_high==0 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA7.xls", ctitle("Affectedness-based Fairness: Low") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributesrev if aff_norm_high==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA7.xls", ctitle("Affectedness-based Fairness: High") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributesrev if need_norm_high==0 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA7.xls", ctitle("Need-based Fairness: Low") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributesrev if need_norm_high==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA7.xls", ctitle("Need-based Fairness: High") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributesrev if gvt_prio_high==0 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA7.xls", ctitle("Electorally-based Fairness: Low") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributesrev if gvt_prio_high==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA7.xls", ctitle("Electorally-based Fairness: High") excel bdec(3) sdec(3) stats(coef se) append

* Appendix Table A.10: Subgroup Results by Damave Levels and Interaction Models
* Interactions
* Subgroups: $24 million damage, $4 million, $1 million, 100K 
* Interactions: 
* $24 million damage AND $10K income
* $24 million damage AND $40K income
* $24 million damage AND $70K income
* $24 million damage AND $100K income
global int3="inc10Xdamage_24m inc40Xdamage_24m inc70Xdamage_24m"
global int2="inc10Xdamage_4m inc40Xdamage_4m inc70Xdamage_4m"
global int1="inc10Xdamage_1m inc40Xdamage_1m inc70Xdamage_1m"

reg relief_ $attributes [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA10.xls", ctitle(empty) excel bdec(3) sdec(3) stats(coef se) replace

reg relief_ $att_dam if damage_100k==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA10.xls", ctitle("Damage: $100k") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $att_dam if damage_1m==1 | damage_4m==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA10.xls", ctitle("Damage: $1M") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $att_dam if damage_4m==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA10.xls", ctitle("Damage: $4M") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $att_dam if damage_24m==1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA10.xls", ctitle("Damage: $24M") excel bdec(3) sdec(3) stats(coef se) append

*reg relief_  $att_dam if damage_24m!=1 [pweight = weight],  cluster(uniqueID) robust
*outreg2 using "$results/reg_interactions.xls", ctitle("Damage: Less than $24M") excel bdec(3) sdec(3) stats(coef se) append

reg relief_ $attributes $int3 $int2 $int1 [pweight = weight],  cluster(uniqueID) robust
outreg2 using "reg_tableA10.xls", ctitle("Interaction Terms") excel bdec(3) sdec(3) stats(coef se) append

exit
